import request from '@u/request.js'

// 商品管理连山推送测试
const baseUrl = '/product/api/business/product/'

// 商品列表信息查询
export function goodList(data) {
  return request({
    // url: '/product/api/business/product/list',
    url: baseUrl + 'list',
    method: 'post',
    data
  })
}

// 新增商品信息
export function addGood(data) {
  return request({
    url: '/product/api/business/product/add',
    method: 'post',
    data
  })
}

// 根据商品id删除商品信息
export function deleteGood(id) {
  return request({
    url: `product/api/business/product/delete/${id}`,
    method: 'get'
  })
}

// 批量删除商品信息
export function deleteGoodMuch(data) {
  return request({
    url: '/product/api/business/product/deleteByCodes',
    method: 'post',
    data
  })
}

// 根据照片id删除商品照片信息
export function deleteImgInfo(id) {
  return request({
    url: `product/api/business/product/deletePhotoById/${id}`,
    method: 'get'
  })
}

// 根据商品编码查询照片信息
export function getPhotoListByCode(id) {
  return request({
    url: `product/api/business/product/getPhotoListByCode/${id}`,
    method: 'get'
  })
}

// 根据商品编码查询商品信息
export function getGoodInfoByCode(id) {
  return request({
    url: `/product/api/business/product/getByCode/${id}`,
    method: 'get'
  })
}

// 根据商品编码获取站点名称
export function getOrgSiteByCode(code) {
  return request({
    url: `/product/api/business/product/getOrgSiteByCode/${code}`,
    method: 'get'
  })
}

// 批量入库商品
export function importInstock(data) {
  return request({
    url: '/product/api/business/product/importInstock',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 批量导入商品
export function importProduct(data) {
  return request({
    url: '/product/api/business/product/importProduct',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 修改商品信息
export function updateProduct(data) {
  return request({
    url: '/product/api/business/product/update',
    method: 'post',
    data
  })
}

// 根据编码修改隐藏状态
export function updateMarkByCode(mark, code) {
  return request({
    url: `product/api/business/product/updateMarkByCode/${mark}/${code}`,
    method: 'get'
  })
}

// 根据编码修改上下架状态
export function updateStatusByCode(status, code) {
  return request({
    url: `product/api/business/product/updateStatusByCode/${status}/${code}`,
    method: 'get'
  })
}

// 商品照片批量上传
export function uploadBatchPhoto(data) {
  return request({
    url: '/product/api/business/product/uploadBatchPhoto',
    method: 'post',
    data
  })
}

// 根据商品编码查询商品入库信息
export function getInstockPageByCode(data) {
  return request({
    url: '/product/api/business/product/getInstockPageByCode',
    method: 'post',
    data
  })
}

// 站点信息查询
export function getSite(data) {
  return request({
    url: '/product/api/business/product/getSite',
    method: 'post',
    data
  })
}

// 确认分配
export function siteAllocate(data) {
  return request({
    url: '/product/api/business/product/siteAllocate',
    method: 'post',
    data
  })
}

// 导入模板下载
export function templateDownload() {
  return request({
    url: `product/api/business/product/templateDownload`,
    method: 'get',
    responseType: 'blob'
  })
}
